import zipfile
from pathlib import Path

path = 'test'
newzip = zipfile.ZipFile('new.zip', 'w')

# 压缩所有文件
for p in Path(path).rglob('*'):
    newzip.write(p, compress_type=zipfile.ZIP_DEFLATED)

newzip.close()
print('done!')